package Server.Model.Base;

import common.routine.JsonUtils;
import redis.protocal.DbInfoMgr;
import redis.protocal.DwcRedisRecord;

public class UserGoldChange {
	static public String reason0 = "浏览器操作";
	static public String reason1 = "救济金";
	static public String reason2 = "购买UU豆";
	static public String reason3 = "表情消耗";
	static public String reason4 = "麻将税收";
	static public String reason5 = "拼十张税收";
	static public String reason6 = "赢三张税收";
	static public String reason7 = "港式十三税收";
	static public String reason8 = "推筒子税收";
	static public String reason9 = "捕鱼消耗";
	static public String reason10 = "捕鱼获得";
	static public String reason11 = "水果机消耗";
	static public String reason12 = "水果机获得";
	static public String reason13 = "老虎机消耗";
	static public String reason14 = "老虎机获得";
	static public String reason15 = "拼十张赢取";
	static public String reason16 = "赢三张赢取";
	static public String reason17 = "港式十三赢取";
	static public String reason18 = "麻将赢取";
	static public String reason19 = "退出补偿";//回收
	static public String reason20 = "分享获得金币";//回收
	static public String reason21 = "推筒子赢取";//回收
	static public String reason22 = "斗地主税收";
	static public String reason23 = "跑得快税收";
	static public String reason24 = "斗地主赢取";
	static public String reason25 = "跑得快赢取";
	static public String reason26 = "港式十三税收";
	static public String reason27 = "港式十三输赢";
	static public String reason28 = "圈主获得税收";
	static public String reason29 = "安徽比鸡税收";
	static public String reason30 = "安徽比鸡输赢";
	static public String reason31 = "水果机输赢";
	static public String reason32 = "万人水果机输赢";
	static public String reason100 = "用户充值";
	static public String reason101 = "用户提现";
	static public String reason102 = "用户存进保险柜";
	static public String reason103 = "用户提出保险柜";
	static public String reason104 = "代理批发";
	static public String reason105 = "用户转让";
	public UserGoldChange(int change,int before,int after,String reason){
		m_change = change;
		m_before = before;
		m_after = after;
		m_reason = reason;
		m_time = System.currentTimeMillis();
	}
	public static void handleGoldChange(int uid,int change,int before,int after,String reason){
		UserGoldChange info = new UserGoldChange(change,before,after,reason);
		DbInfoMgr.getInstance().pushUserGoldChangeInfo(uid, JsonUtils.serialize(info));
	}
	public static void handleGoldChangeKouShui(SecShmUser user,int shui,String reason){
		int after = user.getCoin(0);
		int before = after + shui;
		handleGoldChange(user.getUid(),shui,before,after,reason);
		//这里只处理真人，记录本游戏盈利状况
		if(!user.isAndroidUser()){
			DwcRedisRecord.getInstance().addGoldGameInfo(reason, shui);
		}
	}
	public static void handleGoldChangeWinLose(SecShmUser user,int gold,String reason){
		int after = user.getCoin(0);
		int before = after + gold;
		if(after > before){
			//赢了
		}else{
			//输了
		}
		handleGoldChange(user.getUid(),gold,before,after,reason);
		//这里只处理真人，记录本游戏盈利状况,针对真人的，
		if(!user.isAndroidUser()){
			DwcRedisRecord.getInstance().addGoldGameInfo(reason, -gold);//系统的取负值，真人的正好对消
		}
	}

	public static void hanleGoldChangeBuChang(SHMUser user,int gold,String reason){
		int after = user.getCoin(0);
		int before = after + gold;
		if(after > before){
			//赢了
		}else{
			//输了
		}
		handleGoldChange(user.getUid(),gold,before,after,reason);
	}
	public int m_change;
	public int m_before;
	public int m_after;
	public long m_time;
	public String m_reason;
}
